/**data: 2012-4-24
  *author:fengyuxiang
  *Function 列表数据变色
*/
var Event_handel={
	addEvent:function(type,fn,ele){
		if(ele.attachEvent){
			ele.attachEvent("on"+type,fn);
		}
		else if(ele.addEventListener){
			ele.addEventListener(type,fn,false);
		}
		else{
			ele["on"+type]=fn;
		}
	},
	removeEvent:function(type,fn,ele){
		if(ele.attachEvent){
			ele.detachEvent("on"+type,fn);
		}
		else if(ele.addEventListener){
			ele.removeEventListener(type,fn,false);
		}
		else{
			ele["on"+type]=null;
		}
	},
	getEvent:function(event){
		return event||window.event;
	},
	getTarget:function(event){
		return event.srcElement?event.srcElement:event.target;　
	}
};
(function(d,w){
	w.cur_id=-1;
	var cur_tr_index=-1;
	var class_op={
		addClass:function(elm,newClass){   
			var classes = elm.className.split(' ');
			var classIndex=this.hasClass(elm,newClass);
			if(classIndex==-1)
			classes.push(newClass);
			elm.className = classes.join(' '); 
		},
		hasClass:function(elm,className){
			var classes = elm.className.split(' ');
			for(var a in classes){
				if(classes[a]==className)
				return a;
			}
			return -1;
		},
		delClass:function(elm,className){
    		var classes = elm.className.split(' ');
   			var classIndex=this.hasClass(elm,className);
    		if(classIndex!=-1)classes.splice(classIndex,1);
    		elm.className=classes.join(' '); 
		}
	};

	var tr_event={
		getEle:function(id){
			this[0]=d.getElementById(id).getElementsByTagName("tr");
		},
		event_init:function(self,i,obj,e_type){
			Event_handel.addEvent(e_type,function(){
				if(typeof obj[0][cur_tr_index]!="undefined"){
					class_op.delClass(obj[0][cur_tr_index],"on_td_hover");
				}
				if(self.className.indexOf("on_td_hover")>-1){
						return;
				}
				else{
					class_op.addClass(self,"on_td_hover");
					cur_tr_index=i;
					if(tr_event.is_get_value){
						w.cur_id=self.getAttribute("id");
					}
				}
			},self);
		},
		initEvent:function(op_type,state){
			this["e_type"]=op_type;
			this["is_get_value"]=state;
			if(op_type.length>1){
				for(var i=0;i<this[0].length;i++){
					var self =this[0][i];
					(function(self,i,obj){
						obj.event_init(self,i,obj,obj["e_type"][0]);
					})(self,i,this);
					(function(self,i,obj){
						obj.event_init(self,i,obj["e_type"][1]);
					})(self,i,this);
				}
			}else{
				for(var i=1;i<this[0].length;i++){
					var self =this[0][i];
					(function(self,i,obj){
						obj.event_init(self,i,obj,obj["e_type"][0]);
					})(self,i,this)
				}
			}
		},
	};
	w["tabel_event"]=tr_event;
})(document,window)























































